package init;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import business.Utilerias;

public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	public void init() throws ServletException {
		System.out.println(Utilerias.sistemaLog("Abriendo conecciones"));
		String str_driver = super.getInitParameter("driver");
		String str_driverFormat = super.getInitParameter("driverFormat");
		DBManagement.instancia(str_driver, str_driverFormat, super.getInitParameter("server"), Integer.parseInt( super.getInitParameter("port") ), super.getInitParameter("db"), super.getInitParameter("username"), super.getInitParameter("pass"));
	}
	
	public void destroy() {
		System.out.println(Utilerias.sistemaLog("Cerrando conecciones"));
		DBManagement.closeConnection();
	}
}